import { BaseWindow } from "../../../component/window/BaseWindow";
import { PageTool } from "../../../common/global/PageTool";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { GuildEventName } from "./GuildEventName";
import { Language } from "../../../../extend/language/Language";
import { InviteListPanel } from "./InviteListPanel";
import { DataEvent } from "../../events/DataEvent";
import { Cache } from "../../cache/Cache";
import { GLabel } from "../../../../com/mui/controls/GLabel";
type int = number;
//class InviteListWindow
    
    export  class InviteListWindow extends BaseWindow
    {
        constructor()
        {
            super();
            this._pageTool = new PageTool([], 6);
            this.setSize(525, 275);
            this.titleHeight = 32;
            this.init();
            this.addEventListener(flash.events.Event.CHANGE, this.onCurPageChangeHandler);
            Dispatcher.addEventListener(GuildEventName.DelInviteGuild, this.onDelInviteGuildHanler);
            return;
        }

        /* internal  */init(): void
        {
            this.title = Language.getString(57036);
            this.inviteListPanel = new InviteListPanel();
            this.inviteListPanel.x = 15;
            this.inviteListPanel.y = 40;
            addChild(this.inviteListPanel);
            return;
        }

        public updateListDataProvider(arg1: Array<any>): void
        {
            this._pageTool.array = arg1;
            this.inviteListPanel.updateDataProvider(this._pageTool.getByPageNo(1));
            this.inviteListPanel.pageBar.maxPage = this._pageTool.pagesCount;
            if (arg1.length == 0) 
            {
                this.inviteListPanel.pageBar.currentPage = 1;
            }
            return;
        }

        public onCurPageChangeHandler(arg1: Object /* flash.events.Event */): void
        {
            var loc1=this.inviteListPanel.pageBar.currentPage;
            this.inviteListPanel.updateDataProvider(this._pageTool.getByPageNo(loc1));
            return;
        }

        /* internal  */onDelInviteGuildHanler(arg1: DataEvent): void
        {
            var loc1=arg1.data as int;
            var loc2=Cache.instance.guild.getInviteGuildByGuildId(loc1);
            if (loc2) 
            {
                this.inviteListPanel.tileList.dataProvider.removeItem(loc2);
            }
            return;
        }

        /* internal */ /* var */_titleLabel: GLabel;

        /* internal */ /* var */inviteListPanel: InviteListPanel;

        /* internal */ /* var */_pageTool: PageTool;
    }
